part of 'component.dart';

Widget searchBar(
    {required String hintText,
    TextEditingController? controller,
    VoidCallback? onTap,
    Function(String)? onChanged,
    VoidCallback? onEditingComplete,
    Function(String)? onSubmitted,
    TextStyle? hintStyle,
    TextStyle? labelStyle,
    double? height,
    Color? iconColor,
    Color? borderColor,
    Color? focusBorderColor,
    Color? backgroundColor,
    FocusNode? focusNode,
    required double width}) {
  var _height = height ?? 32.w;
  var _backgroundColor = backgroundColor ?? const Color(0xcc397f58);
  return Container(
    height: _height,
    width: width,
    alignment: Alignment.center,
    child: TextField(
      controller: controller,
      focusNode: focusNode,
      onTap: onTap,
      onChanged: onChanged,
      onEditingComplete: onEditingComplete,
      onSubmitted: onSubmitted,
      textAlignVertical: TextAlignVertical.center,
      decoration: InputDecoration(
          enabledBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? _backgroundColor,
                  width: borderColor == null ? 0 : 1),
              borderRadius: BorderRadius.circular(_height / 2)),
          focusedBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? _backgroundColor,
                  width: borderColor == null ? 0 : 1),
              borderRadius: BorderRadius.circular(_height / 2)),
          disabledBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? _backgroundColor,
                  width: borderColor == null ? 0 : 1),
              borderRadius: BorderRadius.circular(_height / 2)),
          prefixIcon: Icon(
            IconUtil.search,
            size: 15.w,
            color: iconColor ?? const Color(0xfffcfefe),
          ),
          isCollapsed: true,
          filled: true,
          fillColor: backgroundColor ?? const Color(0xcc397f58),
          contentPadding: EdgeInsets.zero,
          border: InputBorder.none,
          labelStyle: labelStyle ??
              pfMediumStyle(fontSize: font15, color: const Color(0xffffffff)),
          hintText: hintText,
          hintStyle: hintStyle ??
              pfMediumStyle(fontSize: font15, color: const Color(0x66ffffff))),
    ),
  );
}

Widget searchFadeBar(
    {required String hintText,
    VoidCallback? onTap,
    TextStyle? hintStyle,
    double? height,
    Color? iconColor,
    Color? backgroundColor,
    required double width}) {
  var _height = height ?? 32.w;
  var _backgroundColor = backgroundColor ?? const Color(0xcc397f58);
  return OpenContainer(
      closedColor: _backgroundColor,
      closedElevation: 0,
      closedShape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(_height / 2))),
      closedBuilder: (context, callback) {
        return Container(
            height: _height,
            width: width,
            alignment: Alignment.center,
            child: Row(
              children: [
                SizedBox(
                  width: 10.r,
                ),
                Icon(
                  IconUtil.search,
                  size: 15.w,
                  color: iconColor ?? const Color(0xfffcfefe),
                ),
                SizedBox(
                  width: 10.r,
                ),
                Text(
                  hintText,
                  style: hintStyle ??
                      pfMediumStyle(
                          fontSize: font15, color: const Color(0x66ffffff)),
                )
              ],
            ));
      },
      openBuilder: (context, _) {
        return SearchPage();
      });
}
